﻿<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="A_ReferenceCodes.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:local="clr-namespace:A_ReferenceCodes"
             xmlns:dm="clr-namespace:DataModel;assembly=DataModel"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <dm:SaveChangesCommand x:Key="Save"/>
        <local:NewRefCodeCommand x:Name="NewRef"/>
        <DataTemplate x:Name="HeaderT">
            <TextBlock Text="{Binding Name}" ToolTipService.ToolTip="{Binding Description}">
            </TextBlock>
        </DataTemplate>
        <DataTemplate x:Name="ContentT">
            <Grid x:Name="RootGrid">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <TextBlock Text="{Binding Description}" TextWrapping="Wrap"/>
                <Button Grid.Column="1" Command="{StaticResource NewRef}" 
                        CommandParameter="{Binding}">Add Ref Code</Button>
                <sdk:DataGrid x:Name="DataG" ItemsSource="{Binding RefCodes}" Grid.Row="1" Grid.ColumnSpan="2" AutoGenerateColumns="False" LoadingRow="DataGrid_LoadingRow">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Header="Short Name" Binding="{Binding ShortName}"/>
                        <sdk:DataGridTextColumn Header="Description" Binding="{Binding Description}"/>
                        <sdk:DataGridTextColumn Header="Weight" Binding="{Binding Weight}"/>
                        <sdk:DataGridTextColumn Binding="{Binding MetaData}">
                            <!--<sdk:DataGridTextColumn.HeaderStyle>
                                <Style TargetType="sdk:DataGridColumnHeader">
                                    <Setter Property="ContentTemplate">
                                        <Setter.Value>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Source={StaticResource MetaDataTitle}, Path=value}"/>
                                            </DataTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </sdk:DataGridTextColumn.HeaderStyle>-->
                        </sdk:DataGridTextColumn>
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <sdk:TabControl ItemsSource="{Binding}"/>
    </Grid>
</UserControl>
